package com.toncen.samepms.fisher.formatter;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import com.toncen.samepms.net.dao.ChannelDao;
import com.toncen.samepms.net.dao.InformationDao;
import com.toncen.samepms.net.domain.ChanelInformation;
import com.toncen.samepms.net.domain.Channel;
import com.toncen.samepms.net.domain.Information;
import com.toncen.samepms.util.SQLUtils;
import com.sky.fisher.formatter.AbstractFormatter;
import com.sky.fisher.model.CommonColumnModel;

public class InformationFormatter extends AbstractFormatter{

	@Override
	public String format(CommonColumnModel column, String source) throws Exception {
		InformationDao informationDao = new InformationDao();
		Information information = informationDao.find(Long.parseLong(source));
		List<ChanelInformation> chanelInformations = information.getChanelInformation();
		Set<Long> channelIds = new HashSet<Long>();
		for(ChanelInformation chanelInformation : chanelInformations){
			channelIds.add(chanelInformation.getChanel().getId());
		}
		
		List<Channel> channels = new ArrayList<Channel>();
		ChannelDao channelDao = new ChannelDao();
		for(Long channelId : channelIds){
			channels.add(channelDao.find(channelId));
		}
		
		return SQLUtils.getInSQL(channels,"name");
		
//		return SQLUtils.getInSQL(roleChannels,"role.id");
	}

}